home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8"?>
- <!-- ===========================================================
- Category: Recursion
- Author: David Silverlight
- HeadGeek@xmlpitstop.com
- Created: 2001-05-16
- Description:-
- This stylsheet demonstrates recursion by removing the
- trailing(rightmost) spaces from an element.
- Note: Since the output is in HTML, you will need to view the
- source of the HTML to see the differences bewtween the
- trimmed and non-trimmed values.
- ================================================================ -->
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
- <xsl:output method="html" indent="yes" />
-
- <xsl:include href="TrimR.xsl" />
-
- <xsl:template match="/">
- <html>
- <head>
- <title>Stylesheet Example</title>
- <style type="text/css"><![CDATA[
- H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
- H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
- .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
- TD {COLOR: darkblue; FONT-FAMILY: Arial}
- TR { background-color: beige; }
- BODY { background-color: beige; }
- ]]></style>
- </head>
- <body>
- <xsl:apply-templates />
- </body>
- </html>
- </xsl:template>
-
- <xsl:template match="employees">
- <h1>Employee listing with trailing spaces removed.</h1>
- <!-- Table Header Creation -->
- <table border="1">
- <tr>
- <th>Name</th>
- <th>Department</th>
- <th>Name(trimmed)</th>
- <th>Department(trimmed)</th>
- </tr>
- <xsl:for-each select="employee">
- <tr>
- <td>
- <xsl:value-of select="employeename" />
- </td>
- <td>
- <xsl:value-of select="department" />
- </td>
- <td>
- <!-- Call the template that will trim off trailing(rightmost) spaces (recursively, of course ) -->
- <xsl:call-template name="TrimR">
- <xsl:with-param name="strInput" select="employeename" />
- </xsl:call-template>
- </td>
- <td>
- <!-- Call the template that will trim off trailing(rightmost) spaces (recursively, of course ) -->
- <xsl:call-template name="TrimR">
- <xsl:with-param name="strInput" select="department" />
- </xsl:call-template>
- </td>
- </tr>
- </xsl:for-each>
- </table>
- </xsl:template>
- </xsl:stylesheet>